using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web;

namespace Provausio.Common.Utility.Extensions
{
    public static class Strings
    {
        /// <summary>
        /// Extension method returns whether or not a string value strictly contains numbers
        /// </summary>
        /// <param name="value"></param>
        /// <returns>boolean describing whether or not the value is numeric</returns>
        public static bool IsNumeric(this string value)
        {
            return new Regex(RegexStrings.Numeric).IsMatch(value);
        }

        public static T ToType<T>(this string obj)
        {
            try
            {
                return (T)Convert.ChangeType(obj, typeof(T));
            }
            catch (Exception)
            {
                return default(T);
            }
        }
    }
}
